package com.ssy.lingxi.settle.accounts.controller;

import com.ssy.lingxi.common.controller.BaseController;
import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.settle.accounts.model.bo.PayProveBO;
import com.ssy.lingxi.settle.accounts.model.vo.request.*;
import com.ssy.lingxi.settle.accounts.model.vo.response.CommunicationPayProveVO;
import com.ssy.lingxi.settle.accounts.model.vo.response.PagePlatformScoreSettlementDetailVO;
import com.ssy.lingxi.settle.accounts.model.vo.response.PlatformScoreSettlementDetailVO;
import com.ssy.lingxi.settle.accounts.model.vo.response.PlatformScoreSettlementVO;
import com.ssy.lingxi.settle.accounts.service.IPlatformScoreSettlementService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 结算能力-平台积分结算管理
 * @author 伍将
 * @date 2020/10/29
 **/
@RestController
@RequestMapping("/settle/accounts/platform/score/settlement")
public class PlatformScoreSettlementController extends BaseController {

    @Resource
    private IPlatformScoreSettlementService service;

    /**
     * 平台积分结算-分页查询积分结算
     * @author 伍将
     * @date 2020/10/29
     **/
    @RequestMapping(value = "/pageReceivableSettlement", method = RequestMethod.GET)
    public Wrapper<PageData<PlatformScoreSettlementVO>> pageReceivableSettlement(HttpServletRequest httpRequest, @Valid PlatformScoreSettlementPageVO pageVO) {
        return service.pageReceivableSettlement(getSysUser(httpRequest), pageVO);
    }

    /**
     * 平台积分结算-获取积分结算详情
     * @author 伍将
     * @date 2020/10/29
     **/
    @RequestMapping(value = "/getReceivableDetail", method = RequestMethod.GET)
    public Wrapper<PlatformScoreSettlementDetailVO> getReceivableDetail(HttpServletRequest httpRequest, Long id) {
        return service.getReceivableDetail(getSysUser(httpRequest), id);
    }

    /**
     * 平台积分结算-分页查询积分结算明细
     * @author 伍将
     * @date 2020/10/30
     **/
    @RequestMapping(value = "/pageReceivableSettlementDetail", method = RequestMethod.GET)
    public Wrapper<PageData<PagePlatformScoreSettlementDetailVO>> pageReceivableSettlementDetail(HttpServletRequest httpRequest, @Valid PlatformScoreSettlementDetailPageVO pageVO) {
        return service.pageReceivableSettlementDetail(getSysUser(httpRequest), pageVO);
    }

    /**
     * 平台积分结算-分页查询积分结算明细-详情-查询明细导出
     * @param request 令牌
     * @param response 响应
     * @param queryParameter 查询条件
     */
    @RequestMapping(value = "/receivable/export", method = RequestMethod.GET)
    public void receivableExport(HttpServletRequest request, HttpServletResponse response, @Valid PlatformScoreSettlementDetailPageVO queryParameter) {
        service.receivableExport(getSysUser(request), response, queryParameter);
    }

    /**
     * 平台积分结算-确认对账完成
     * @author 伍将
     * @date 2020/10/29
     **/
    @RequestMapping("/confirmAccountComplete")
    public Wrapper<Void> confirmAccountComplete(HttpServletRequest httpRequest, @RequestBody @Valid ConfirmAccountCompleteVO completeVO) {
        return service.confirmAccountComplete(getSysUser(httpRequest), completeVO);
    }

    /**
     * 平台积分结算-确认付款凭证
     * @author 伍将
     * @date 2020/10/29
     **/
    @RequestMapping("/confirmPayProve")
    public Wrapper<Void> confirmPayProve(HttpServletRequest httpRequest, @RequestBody @Valid ConfirmPayProve confirmVO) {
        return service.confirmPayProve(getSysUser(httpRequest), confirmVO);
    }

    /**
     *  平台积分结算-收款方查看凭证
     * @author 伍将
     * @date 2020/10/29
     **/
    @RequestMapping(value = "/getReceivablePayProve", method = RequestMethod.GET)
    public Wrapper<List<PayProveBO>> getReceivablePayProve(HttpServletRequest httpRequest, Long id) {
        return service.getReceivablePayProve(getSysUser(httpRequest), id);
    }

    /**
     * 平台结算管理-积分结算-分页查询积分结算
     * @author 伍将
     * @date 2020/10/29
     **/
    @RequestMapping(value = "/pagePayableSettlement", method = RequestMethod.GET)
    public Wrapper<PageData<PlatformScoreSettlementVO>> pagePayableSettlement(HttpServletRequest httpRequest, @Valid PlatformScoreSettlementPageVO pageVO) {
        return service.pagePayableSettlement(getSysUser(httpRequest), pageVO);
    }

    /**
     * 平台结算管理-积分结算-获取积分结算详情
     * @author 伍将
     * @date 2020/10/29
     **/
    @RequestMapping(value = "/getPayableDetail", method = RequestMethod.GET)
    public Wrapper<PlatformScoreSettlementDetailVO> getPayableDetail(HttpServletRequest httpRequest, Long id) {
        return service.getPayableDetail(getSysUser(httpRequest), id);
    }

    /**
     * 平台结算管理-积分结算-分页查询积分结算明细
     * @author 伍将
     * @date 2020/10/30
     **/
    @RequestMapping(value = "/pagePayableSettlementDetail", method = RequestMethod.GET)
    public Wrapper<PageData<PagePlatformScoreSettlementDetailVO>> pagePayableSettlementDetail(HttpServletRequest httpRequest, @Valid PlatformScoreSettlementDetailPageVO pageVO) {
        return service.pagePayableSettlementDetail(getSysUser(httpRequest), pageVO);
    }

    /**
     * 平台结算管理-积分结算-详情-导出excel
     * @param request 请求
     * @param response 响应
     * @param queryParameter 查询条件
     */
    @RequestMapping(value = "/payable/export", method = RequestMethod.GET)
    public void payableExport(HttpServletRequest request, HttpServletResponse response, @Valid PlatformScoreSettlementDetailPageVO queryParameter) {
        service.payableExport(getSysUser(request), response, queryParameter);
    }

    /**
     * 平台结算管理-积分结算-付款
     * @author 伍将
     * @date 2020/10/29
     **/
    @RequestMapping("/pay")
    public Wrapper<Void> pay(HttpServletRequest httpRequest, @RequestBody @Valid PayVO payVO) {
        return service.pay(getSysUser(httpRequest), payVO);
    }

    /**
     * 平台结算管理-积分结算-付款方查看凭证
     * @author 伍将
     * @date 2020/10/29
     **/
    @RequestMapping(value = "/getPayablePayProve", method = RequestMethod.GET)
    public Wrapper<List<PayProveBO>> getPayablePayProve(HttpServletRequest httpRequest, Long id) {
        return service.getPayablePayProve(getSysUser(httpRequest), id);
    }

    /**
     * 平台结算管理-积分结算-通联付款
     * @param httpRequest 请求
     * @param payVO 积分结算id
     * @return 支付结果
     */
    @RequestMapping(value = "/all/in/pay", method = RequestMethod.POST)
    public Wrapper<Void> allInPay(HttpServletRequest httpRequest, @RequestBody @Valid AllInPayVO payVO) {
        return service.allInPay(getSysUser(httpRequest), payVO);
    }

    /**
     * 平台结算管理-积分结算-付款方查看凭证
     * @param httpRequest 请求
     * @param id 积分结算id
     * @return -付款方查看凭证
     */
    @RequestMapping(value = "/get/all/in/payable/pay/prove", method = RequestMethod.GET)
    public Wrapper<CommunicationPayProveVO> getAllInPayablePayProve(HttpServletRequest httpRequest, Long id) {
        return service.getAllInPayablePayProve(getSysUser(httpRequest), id);
    }
}
